<template>
  <div class="login-log-list">
    <de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" class="pa-5">
      <avue-crud
        ref="crud"
        v-model="form"
        :page.sync="page"
        :data="tableData"
        :table-loading="tableLoading"
        :option="tableOption"
        :search.sync="searchForm"
        @on-load="loadListData"
        @search-change="onSearchChange"
        @search-reset="onSearchReset"
        @refresh-change="onRefresh"
        @selection-change="onSelectionChange"
        @filter-change="onFilterChange"
        @sort-change="onSortChange"
        @row-save="onRowSave"
        @row-update="onRowUpdate"
        @row-del="onRowDelete"
      >
        <template slot="createdAtSearch" slot-scope="{ size }">
          <el-date-picker
            v-model="daterange"
            :size="size"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            @change="onDateRangeChange"
          >
          </el-date-picker>
        </template>
        <template slot="menu" slot-scope="{ row, index, size }">
          <el-button type="text" icon="el-icon-edit" :size="size" @click="$refs.crud.rowEdit(row, index)">
            编辑
          </el-button>
          <el-button :disabled="row.matrixNum" icon="el-icon-delete" type="text" :size="size" @click="onRowDelete(row)"
            >删除</el-button
          >
        </template>
      </avue-crud>
    </de-container>
  </div>
</template>

<script>
import {
  requestMatrixLabelPage,
  requestMatrixLabelSave,
  requestMatrixLabelUpdate,
  requestMatrixLabelDelete,
} from '@/api/chart/chart'
import DeContainer from '@/components/dataease/DeContainer'
import ListMixin from '@/utils/mixins/list-mixin'

const DEFAULT_LIST_MAP_FUNC = (item) => {
  const ret = item

  return ret
}
const DEFAULT_EDIT_MAP_FUNC = (item) => {
  const ret = item
  item.switching = false

  return ret
}
export default {
  name: 'Chart',
  components: { DeContainer },
  mixins: [ListMixin],
  data() {
    return {
      listApi: requestMatrixLabelPage,
      createApi: requestMatrixLabelSave,
      updateApi: requestMatrixLabelUpdate,
      deleteApi: requestMatrixLabelDelete,
      listMapFunc: DEFAULT_LIST_MAP_FUNC,
      editMapFunc: DEFAULT_EDIT_MAP_FUNC,
      tableOption: {
        menuWidth: 320,
        delBtn: false,
        editBtn: false,
        selection: false,
        index: true,
        searchLabelWidth: 100,
        searchMenuPosition: 'left',
        column: [
          {
            label: '标签名称',
            prop: 'name',
            search: true,
            span: 12,
            align: 'left',
            editDisabled: true,
            overHidden: true,
          },
          {
            label: '标签描述',
            prop: 'description',
            span: 12,
            align: 'left',
            overHidden: true,
          },
          {
            label: '指标标记数',
            prop: 'matrixNum',
            editDisplay: false,
            addDisplay: false,
            span: 12,
            align: 'left',
            overHidden: true,
          },
          {
            label: '创建时间',
            prop: 'createdAt',
            editDisplay: false,
            addDisplay: false,
            span: 24,
            width: 150,
            align: 'center',
          },
        ],
      },
    }
  },
  methods: {},
}
</script>

<style lang="scss"></style>
